<?php
namespace App\Http\Controllers\Admin\Mall;


use App\Service\Admin\Mall\OrderService;
use Illuminate\Http\Request;

class OrderController extends BaseController
{
    //商城订单

    //列表
    public function index()
    {
        $res = OrderService::index();
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson(0, '', $res['data'], $res['total']);
    }

    //支付
    public function pay(Request $request)
    {
        $id = $request->post('id', 0);
        $res = OrderService::pay($id);
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson();
    }

    //发货
    public function send(Request $request)
    {
        $id = $request->post('id', 0);
        $res = OrderService::send($id);
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson();
    }

    //完成
    public function finish(Request $request)
    {
        $id = $request->post('id', 0);
        $res = OrderService::finish($id);
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson();
    }
}